<template>
  <div class="app-container">

  </div>
</template>

<script>
import html2canvas from 'html2canvas'

export default {

  methods:{
    saveFile(data, filename) {
      const save_link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');
      save_link.href = data;
      save_link.download = filename;

      const event = document.createEvent('MouseEvents');
      event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
      save_link.dispatchEvent(event);
    },
    clickGeneratePicture() {
      html2canvas(document.querySelector("#capture")).then(canvas => {
        // 转成图片，生成图片地址
        this.imgUrl = canvas.toDataURL("image/png");
        this.saveFile(this.imgUrl, new Date().toLocaleString())
        console.log(this.imgUrl);
        this.firstFlag = false;
      });
    },
  }

}
</script>

<style scoped>
  @import './css/style.css';
</style>
